<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>change_password_update (UsersController)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File users_controller.rb, line 187</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change_password_update</span>
        <span class="ruby-keyword kw">if</span> <span class="ruby-constant">User</span>.<span class="ruby-identifier">authenticate</span>(<span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">login</span>, <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:old_password</span>])
            <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:password</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:password_confirmation</span>]) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">params</span>[<span class="ruby-identifier">:password_confirmation</span>].<span class="ruby-identifier">blank?</span>)
                <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">password_confirmation</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:password_confirmation</span>]
                <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">password</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:password</span>]
                
                <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">save!</span>
                    <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">&quot;Password actualizado con exito. Ujuuuu!&quot;</span>
                    <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">change_password_path</span>
                <span class="ruby-keyword kw">else</span>
                    <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:alert</span>] = <span class="ruby-value str">&quot;Password no cambiado.&quot;</span>
                    <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'change_password'</span>
                <span class="ruby-keyword kw">end</span>
                 
            <span class="ruby-keyword kw">else</span>
                <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:alert</span>] = <span class="ruby-value str">&quot;No coincide el nuevo password&quot;</span> 
                <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'change_password'</span>
            <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">else</span>
            <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:alert</span>] = <span class="ruby-value str">&quot;Password antiguo, incorrecto.&quot;</span> 
            <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'change_password'</span>
        <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span></pre>
</body>
</html>